package org.aeon.heroicsagatextedition.role.product;

import org.aeon.heroicsagatextedition.constants.CommonlyConstants;

/**
 * @projectName: HeroicSagaTextEdition
 * @package: org.aeon.heroicsagatextedition.role.product
 * @className: Hero
 * @author: MissingAeon
 * @date: 2023/12/22 13:01
 * @description: 英雄类，包含英雄的属性和方法。
 */
public class Hero extends RoleUnit {

    private static final int MAX_HP = 600;                                  // 默认最大生命
    private static final int SUPER_WEAPONS_Attack = 100;                    // 超级武器增幅伤害
    private static final int LIFE_SAVING_PILL_REPLY_VOLUME = 200;           // 救命药丸回复量
    private static final int LIFE_SAVING_PILL_MAXIMUM_QUANTITY = 3;       // 救命药丸最大数量

    public Hero(String name) {
        super(name, MAX_HP);
        maxAttack = 100;
        lifeSavingPillCount = LIFE_SAVING_PILL_MAXIMUM_QUANTITY;
    }

    public int getCamp() {
        return CommonlyConstants.RIGHTEOUS;
    }

    /**
     * 超级攻击武器：
     * 此武器的出现需要运气成份，当英雄攻击回合，若能在1-100间得到5的倍数的幸运值，则可以使用此武器，每次使用攻击力在原有基础上增加100
     *
     * @return 攻击力
     */
    @Override
    public int getAttack() {
        // attack += attack % 5 == 0 ? 100 : 0;
        int attack = super.getAttack();
        if (getCamp() == CommonlyConstants.RIGHTEOUS && attack > 0 && attack % 5 == 0) {
            attack += SUPER_WEAPONS_Attack;
            System.out.println(name + "使用了超级攻击武器!");
        }
        return attack;
    }

    /**
     * 救命药丸使用
     *
     * @return
     */
    @Override
    public boolean usingPills() {
        if (lifeSavingPillCount > 0) {
            System.out.println("使用了救命药丸！");
            lifeSavingPillCount--;
            hp = Math.min(maxHp, hp + LIFE_SAVING_PILL_REPLY_VOLUME);
            System.out.println("剩余血量剩余:" + hp);
            return true;
        } else {
            System.out.println("救命药丸剩余数量不足！使用失败！");
            return false;
        }
    }
}
